package com.fly.lambda.dao;

import com.fly.lambda.domain.Config;
import com.fly.lambda.framework.dao.BaseDAO;
import com.fly.lambda.framework.dao.Pagination;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Fly on 2016/7/27.
 */
@Repository
public class ConfigDAO extends BaseDAO<Config> {

    public Pagination<Config> queryConfigPage(String queryStr, int curPage, int pageSize){
        StringBuilder hql = new StringBuilder("from Config where 1 = 1");
        List<Object> params = new ArrayList<Object>();
        if (StringUtils.isNotBlank(queryStr)){
            //查询条件不为空，拼接查询条件
            hql.append(" and config_name like ?");
            params.add("%" + queryStr + "%");
        }
        return doQueryPage(hql.toString(), true, curPage, pageSize, params.toArray());
    }

}
